﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_5
{
    public partial class Form1 : Form
    {
        private int i = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // 使用项目资源
            this.BackgroundImage = Properties.Resources.flower;
            pictureBox1.Image = Properties.Resources.bfly2;

            this.BackgroundImageLayout = ImageLayout.Stretch;
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.BackColor = Color.Transparent;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            i++;
            if (i % 2 == 0)
                pictureBox1.Image = Properties.Resources.bfly2;
            else
                pictureBox1.Image = Properties.Resources.bfly1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // 开始按钮
            timer1.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 停止按钮
            timer1.Enabled = false;
            pictureBox1.Image = System.Drawing.Image.FromFile("bfly2.png");
        }
    }
}
